<template>
  <div class="jingshu">
    <div class="content_title">
      <span>
        <span class="content_text">精梳</span>
        <img class="content_img" src="@/assets/img/chart/liumian.png" alt="" srcset="" />
      </span>
    </div>
    <div class="jingshu_body">
      <div class="jingshu_Col">
        <div v-for="(item, index) in cushaData.cushaDataRow1Data" :key="index + 'a'" class="jingshu_item">
          <template v-if="index == 5">
            <div @click="clickHandle(item)">
              <jingshu2 :data="item" />
            </div>
            <div @click="clickHandle(item)">
              <jingshu3 :data="item" />
            </div>
          </template>
          <div @click="clickHandle(item)">
            <jingshu :data="item"></jingshu>
          </div>
        </div>
      </div>
      <div class="jingshu_Col">
        <div class="dongli" @click="clickHandleDl('jingtiao_')">
          <img src="@/assets/img/dongligui.png" alt="" srcset="" />
        </div>
        <div v-for="(item, index) in cushaData.cushaDataRow1Data" :key="index + 'a'" class="jingshu_item">
          <template v-if="index == 5">
            <div @click="clickHandle(item)">
              <jingshu2 :data="item"></jingshu2>
            </div>
            <div @click="clickHandle(item)">
              <jingshu3 :data="item" />
            </div>
          </template>
          <div @click="clickHandle(item)">
            <jingshu :data="item"></jingshu>
          </div>
        </div>
        <div class="dongli" @click="clickHandleDl('jingtiao_')">
          <img src="@/assets/img/dongligui.png" alt="" srcset="" />
        </div>
      </div>
      <div class="jingshu_Col" style="justify-content: flex-start" v-if="false">
        <div
          v-for="(item, index) in jingtiaoData.jingtiaoCol1Data"
          :key="index + 'f'"
          class="jingtiao_item"
          @click="clickHandle('jingtiao', item)"
        >
          <jingtiaor :data="item"></jingtiaor>
        </div>
      </div>
    </div>
    <!-- 粗纱弹窗控件 -->
    <!-- <cushaDialog ref="cushaDialog"></cushaDialog> -->
    <!-- 动力柜弹窗控件 -->
    <!-- <dongliDialog ref="dongliDialog"></dongliDialog> -->
  </div>
</template>

<script>
// import dongliDialog from '@/views/monitorCenter/workChart/components/qcs/dialog/dialog_dongli/index'
// import cushaDialog from '@/views/monitorCenter/workChart/components/qcs/dialog/dialog_cusha/index'
import jingshu from '@/views/monitorCenter/workChart/components/qcs/jingshu/index.vue'
import jingshu2 from '@/views/monitorCenter/workChart/components/qcs/jingshu/index2.vue'
import jingshu3 from '@/views/monitorCenter/workChart/components/qcs/jingshu/index3.vue'
import COMMON from '@/utils/common'
import dongLiMenu from '@/assets/data/dongli.json'
import dongliItem from '@/assets/data/dongliItem.json'
import jingtiaor from '@/views/monitorCenter/workChart/components/qcs/jingtiao_r'
export default {
  name: 'JingShu',
  props: {
    msg: String,
    // 是否嵌套在弹窗内
    inline: {
      type: Boolean,
      default: false
    }
  },
  components: {
    // dongliDialog,
    jingshu,
    jingshu2,
    jingshu3,
    jingtiaor,
    // cushaDialog
  },
  data() {
    return {
      cushaData: {
        // 1-14
        cushaDataRow1Data: [],
        // 15-16
        cushaDataRow2Data: [],
        dongLiMenu: {},
        dongLiItem: {}
      },
      jingtiaoData: {
        // 1-12
        jingtiaoCol1Data: []
      },
      techShow: false
    }
  },
  created() {
    this.dongLiMenu = dongLiMenu
    this.dongLiItem = dongliItem
  },
  computed: {
    bingTiaoGroupState() {
      return this.$store.state.workshop.bingTiaoGroupState
    },
    txcsomlGroupState() {
      return this.$store.state.workshop.txcsomlGroupState
    }
  },
  watch: {
    txcsomlGroupState: {
      immediate: true,
      handler(val) {
        this.cushaData.cushaDataRow1Data = COMMON.devSnFilter(val, 1, 12)
      }
    },
    bingTiaoGroupState: {
      immediate: true,
      handler(val) {
        this.jingtiaoData.jingtiaoCol1Data = COMMON.devSnFilter(val, 1, 8)
      }
    }
  },
  methods: {
    closeHandle(type) {
      // 若细砂组件在1.5级弹窗内，当关闭二级弹窗时，需要打开1.5级的轮询
      if (this.inline) {
        // 关闭二级轮询
        this.$EventBus.$emit('clearTypeInterval', type)
        this.$parent.$parent.getTableData()
      } else {
        this.$parent.closeParentHandle()
      }
    },
    clickHandle(item) {
      // 旧粗纱:新粗纱
      let type = item.emp == '0' ? 'TXCSOML' : 'CUSHA'
      // 若细砂组件在1.5级弹窗内，当打开二级弹窗时，需要关闭1.5级的轮询
      if (this.inline) {
        this.$EventBus.$emit('getInfoByDevSn', type, item.devSn)
        this.$EventBus.$emit('inlineDialog', 'close')
      } else {
        this.$parent.getInfoByDevSn(type, item.devSn)
      }
      this.$refs.cushaDialog.showDialog(item)
    },
    clickHandleDl(item) {
      var getInfoQuary = this.dongLiMenu[item]
      var dialogData = this.dongLiItem[item]
      // 若细砂组件在1.5级弹窗内，当打开二级弹窗时，需要关闭1.5级的轮询
      if (this.inline) {
        this.$EventBus.$emit('getInfoByDevSn', 'DONGLI', getInfoQuary)
        this.$EventBus.$emit('inlineDialog', 'close')
      } else {
        this.$parent.getInfoByDevSn('DONGLI', getInfoQuary)
      }
      this.$refs.dongliDialog.showDialog(dialogData)
    },
    showDialogTech() {
      this.techShow = true
      this.$nextTick(() => {
        setTimeout(() => {
          // 初始化请求
          // 1.5级轮询
          this.$parent.openInlineDialog('CUSHA', { start: 1, end: 16 })
          this.$refs.cushaDialogTech.showDialog()
        })
      })
    },
    closeDialogTech() {
      this.techShow = false
      this.$parent.closeParentHandle()
    }
  }
}
</script>

<style lang="less" scoped>
@import '~@/assets/less/workshop.less';
</style>
